<?php
class Osml_Controller_Admin_Action extends \Jnd_Controller_Admin_Action
{

    /**
     *
     * @see Jnd_Controller_Admin_Action::init()
     */
    public function init()
    {
        parent::init();
        
        $class_ul_current = "current";
        $class_ul_detail_current = "show";
        $class_ul = "select";
        $class_ul_detail = "";
        
        // Initialisation des valeurs par défaut
        $this->view->class_ul_accueil = $class_ul;
        $this->view->class_ul_accueil_detail = $class_ul_detail;
        $this->view->class_ul_utilisateurs = $class_ul;
        $this->view->class_ul_utilisateurs_detail = $class_ul_detail;
        $this->view->class_ul_news = $class_ul;
        $this->view->class_ul_news_detail = $class_ul_detail;
        $this->view->class_ul_liens = $class_ul;
        $this->view->class_ul_liens_detail = $class_ul_detail;
        $this->view->class_ul_droits = $class_ul;
        $this->view->class_ul_droits_detail = $class_ul_detail;
        $this->view->class_ul_pages = $class_ul;
        $this->view->class_ul_pages_detail = $class_ul_detail;
        $this->view->class_ul_saisons = $class_ul;
        $this->view->class_ul_saisons_detail = $class_ul_detail;
		$this->view->class_ul_galerie = $class_ul;
        $this->view->class_ul_galerie_detail = $class_ul_detail;
        
        $request = $this->getRequest();
        switch ($request->getControllerName())
        {
            case "utilisateurs":
            case "groupes":
                $this->view->class_ul_utilisateurs = $class_ul_current;
                $this->view->class_ul_utilisateurs_detail = $class_ul_detail_current;
            break;
            case "news":
                $this->view->class_ul_news = $class_ul_current;
                $this->view->class_ul_news_detail = $class_ul_detail_current;
            break;
            case "liens":
                $this->view->class_ul_liens = $class_ul_current;
                $this->view->class_ul_liens_detail = $class_ul_detail_current;
            break;
            case "pages":
                $this->view->class_ul_pages = $class_ul_current;
                $this->view->class_ul_pages_detail = $class_ul_detail_current;
            break;
            case "saisons":
                $this->view->class_ul_saisons = $class_ul_current;
                $this->view->class_ul_saisons_detail = $class_ul_detail_current;
            break;
            case "droits":
            case "roles":
            case "ressources":
                $this->view->class_ul_droits = $class_ul_current;
                $this->view->class_ul_droits_detail = $class_ul_detail_current;
            break;
            case "galerie":
                $this->view->class_ul_galerie = $class_ul_current;
                $this->view->class_ul_galerie_detail = $class_ul_detail_current;
            break;			
            case "index":
                $this->view->class_ul_accueil = $class_ul_current;
                $this->view->class_ul_accueil_detail = $class_ul_detail_current;
            break;
        }
        
        if (Zend_Auth::getInstance()->getIdentity() == "" && $this->getRequest()->getActionName() != "connexion") {
            $this->redirect("connexion", "index", "back");
        } elseif (Zend_Auth::getInstance()->getIdentity() != "") {
            // On est connecté on vérifie qu'on est bien administrateur
            $user = Jnd_App::getEnvironnement()->getUtilisateurCourant();
            // $flag = $user->appartientAuGroupe('ADMINISTRATEURS');
            // if ($flag === false) {
            // throw new Exception(
            // 'Vous devez être admin pour utiliser le back office');
            // }
        }
        
        $acl = new Osml_Acl();
    }
}

